/*
 * @Author: ckk
 * @Date: 2023-07-12 09:40:16
 * @LastEditTime: 2023-08-22 16:38:40
 * @Description: 基本信息
 * @version: 1.0
 */
import axios from './request';
import { getHost } from '@/utils';

// 获取Domain地址
export async function getDomain (type) {
  const { data } = await axios.get(
    `/gw/baseapi/uconfig/cfg/${type}`
  );
  return (data || {});
}

/**
 * @Desc 获取门户头部底部数据
 * @param name 域名
 * @param target json名称
 */
export async function HttpGetProtalJson ({ name, target }) {
  try {
    const time = new Date().getTime(),
      { data } = await axios.get(`/protal/head_foot/${name}/${target}?v=${time}`);

    return data;
  } catch (e) {
    return undefined;
  }
}

/**
 * @Desc 返回门户头部信息
 */
export function getStaticProtalJson () {
  // getHost()
  console.log(getHost());
  return HttpGetProtalJson({ name: 'cs.yjt361.com', target: 'headfoot.json' });
}
/**
 * @author: ckk
 * @description: 获取学习咨询的链接
 * @param {*} params
 * @return {*}
 */
export async function getStudyLink (params) {
  const { data } = await axios.post('/api/v1/icss/customerInfo', { ...params }, {
    headers: { Authorization: `Bearer ${JSON.parse(decodeURIComponent(localStorage.getItem('auth_token'))).access_token}`, 'content-type': 'application/json' }
  });
  return (data || {});
}
/**
 * @description:获取一组目录（目前支持学科产品编码、专项课程编码等）的打vip标签
 * @return:
 */
export async function getTemVips (params) {
  const { data } = await axios.get(`${process.env.VUE_APP_NRMS_URL}/rms/v1/catalogue/get_vips`, {
    params
  });
  return data;
}
